home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / utilities / text / less-278.lha / less-278 / src.lha / source / configure.in < prev    next >
Encoding:
Text File  |  1995-02-01  |  5.4 KB  |  161 lines

  1. dnl Process this file with autoconf to produce a configure script.
  2. AC_INIT(forwback.c)
  3. AC_CONFIG_HEADER(defines.h)
  4.  
  5. dnl Checks for programs.
  6. AC_PROG_CC
  7. AC_ISC_POSIX
  8. AC_PROG_GCC_TRADITIONAL
  9. AC_PROG_INSTALL
  10.  
  11. dnl Checks for libraries.
  12. TERMLIBS=
  13. AC_CHECK_LIB(curses, initscr, [TERMLIBS="$TERMLIBS -lcurses"])
  14. AC_CHECK_LIB(termcap, tgetent, [TERMLIBS="$TERMLIBS -ltermcap"])
  15. AC_CHECK_LIB(termlib, tgetent, [have_termlib=yes], [have_termlib=no])
  16. dnl Regular expressions (regcmp) are in -lgen on Solaris 2,
  17. dnl and in -lintl on SCO Unix.
  18. AC_CHECK_LIB(gen, regcmp)
  19. AC_CHECK_LIB(intl, regcmp)
  20.  
  21. dnl Solaris has curses & termcap, but they don't work without libucb
  22. dnl which is broken, so we use termlib.
  23. AC_MSG_CHECKING(for working terminal libraries)
  24. SAVE_LIBS=$LIBS
  25. LIBS="$LIBS $TERMLIBS"
  26. AC_TRY_LINK(, [tgetent(0); tgetflag(0); tgetnum(0); tgetstr(0);],
  27.   [termok=yes], [termok=no])
  28. if test $termok = yes; then
  29.   AC_MSG_RESULT(using $TERMLIBS)
  30. else
  31.   LIBS="$SAVE_LIBS"
  32.   if test $have_termlib = yes; then
  33.     LIBS="$LIBS -ltermlib"
  34.     AC_MSG_RESULT(using -ltermlib)
  35.   else
  36.     AC_MSG_RESULT(TERMINAL LIBRARY BROKEN - configure failed)
  37.     exit 1
  38.   fi
  39. fi
  40.  
  41. dnl Checks for header files.
  42. AC_HEADER_STDC
  43. AC_CHECK_HEADERS(ctype.h errno.h fcntl.h stdio.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h sys/ptem.h)
  44.  
  45. dnl Checks for identifiers.
  46. AC_TYPE_OFF_T
  47. AC_MSG_CHECKING(for void)
  48. AC_TRY_COMPILE(, [void *foo = 0;], 
  49.   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_VOID)], [AC_MSG_RESULT(no)])
  50. AC_MSG_CHECKING(for time_t)
  51. AC_TRY_COMPILE([#include <time.h>], [time_t t = 0;],
  52.   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIME_T)], [AC_MSG_RESULT(no)])
  53.  
  54. dnl Checks for functions and external variables.
  55. AC_TYPE_SIGNAL
  56. AC_CHECK_FUNCS(_setjmp system sigsetmask memcpy strchr)
  57. dnl Some systems have termios.h but not the corresponding functions.
  58. AC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS))
  59. AC_MSG_CHECKING(for fileno)
  60. AC_TRY_LINK([
  61. #if HAVE_STDIO_H
  62. #include <stdio.h>
  63. #endif], [static int x; x = fileno(stdin);],
  64.   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FILENO)], [AC_MSG_RESULT(no)])
  65. AC_MSG_CHECKING(for strerror)
  66. AC_TRY_LINK([
  67. #if HAVE_STDIO_H
  68. #include <stdio.h>
  69. #endif
  70. #if HAVE_STRING_H
  71. #include <string.h>
  72. #endif
  73. #if HAVE_ERRNO_H
  74. #include <errno.h>
  75. #endif], [static char *x; x = strerror(0);],
  76.   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRERROR)], [AC_MSG_RESULT(no)])
  77. AC_MSG_CHECKING(for sys_errlist)
  78. AC_TRY_LINK(, [extern char *sys_errlist[]; static char **x; x = sys_errlist;], 
  79.   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYS_ERRLIST)], [AC_MSG_RESULT(no)])
  80. AC_MSG_CHECKING(for errno)
  81. AC_TRY_LINK(, [extern int errno; static int x; x = errno;], 
  82.   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ERRNO)], [AC_MSG_RESULT(no)])
  83. AC_MSG_CHECKING(for locale)
  84. AC_TRY_LINK([#include <locale.h>
  85. #include <ctype.h>], [setlocale(LC_CTYPE,""); isprint(0); iscntrl(0);],
  86.   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_LOCALE)], [AC_MSG_RESULT(no)])
  87. AC_MSG_CHECKING(for ctype functions)
  88. AC_TRY_LINK([
  89. #if HAVE_CTYPE_H
  90. #include <ctype.h>
  91. #endif], [static int x; x = isupper(x); x = tolower(x); x = toupper(x);],
  92.   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UPPER_LOWER)], [AC_MSG_RESULT(no)])
  93.  
  94. dnl Checks for external variable ospeed in the termcap library.
  95. have_ospeed=no
  96. AC_MSG_CHECKING(termcap for ospeed)
  97. AC_TRY_LINK([
  98. #include <sys/types.h>
  99. #if HAVE_TERMIOS_H
  100. #include <termios.h>
  101. #endif
  102. #if HAVE_TERMCAP_H
  103. #include <termcap.h>
  104. #endif], [ospeed = 0;],
  105. [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED) have_ospeed=yes])
  106. if test $have_ospeed = no; then
  107. AC_TRY_LINK(, [extern short ospeed; ospeed = 0;], 
  108.   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED) AC_DEFINE(MUST_DEFINE_OSPEED)],
  109.   [AC_MSG_RESULT(no)])
  110. fi
  111.  
  112. dnl Checks for regular expression functions.
  113. have_regex=no
  114. have_posix_regex=unknown
  115. AC_CHECKING(for regular expression library)
  116. dnl Some versions of Solaris have a regcomp() function, but it doesn't work!
  117. dnl So we run a test program.  If we're cross-compiling, do it the old way.
  118. AC_TRY_RUN([
  119. #include <sys/types.h>
  120. #include <regex.h>
  121. main() { regex_t r; regmatch_t rm;
  122. if (regcomp(&r, "abc", 0)) exit(1);
  123. if (regexec(&r, "xabcy", 1, &rm, 0)) exit(1);
  124. exit(0); }],
  125.   have_posix_regex=yes, have_posix_regex=no, have_posix_regex=unknown)
  126. if test $have_posix_regex = yes; then
  127.   AC_MSG_RESULT(using POSIX regcomp)
  128.   AC_DEFINE(HAVE_POSIX_REGCOMP)
  129.   have_regex=yes
  130. elif test $have_posix_regex = unknown; then
  131.   AC_TRY_LINK([
  132. #include <sys/types.h>
  133. #include <regex.h>],
  134.   [regex_t *r; regfree(r);],
  135.   AC_MSG_RESULT(using POSIX regcomp)
  136.   AC_DEFINE(HAVE_POSIX_REGCOMP) have_regex=yes)
  137. fi
  138. if test $have_regex = no; then
  139. AC_CHECK_FUNC(regcmp, 
  140. AC_MSG_RESULT(using regcmp); AC_DEFINE(HAVE_REGCMP) have_regex=yes)
  141. fi
  142. if test $have_regex = no; then
  143. AC_TRY_LINK([
  144. #include "regexp.h"], [regcomp("");],
  145. AC_MSG_RESULT(using V8 regcomp); AC_DEFINE(HAVE_V8_REGCOMP) have_regex=yes)
  146. fi
  147. if test $have_regex = no && test -f ${srcdir}/regex.c; then
  148. AC_MSG_RESULT(using POSIX regcomp -- local source); AC_DEFINE(HAVE_POSIX_REGCOMP) REGEX_O='regex.$(O)' AC_SUBST(REGEX_O) have_regex=yes
  149. fi
  150. if test $have_regex = no && test -f ${srcdir}/regexp.c; then
  151. AC_MSG_RESULT(using V8 regcomp -- local source); AC_DEFINE(HAVE_V8_REGCOMP) REGEX_O='regexp.$(O)' AC_SUBST(REGEX_O) have_regex=yes
  152. fi
  153. if test $have_regex = no; then
  154. AC_MSG_RESULT(using re_comp); AC_CHECK_FUNC(re_comp, AC_DEFINE(HAVE_RE_COMP) have_regex=yes)
  155. fi
  156. if test $have_regex = no; then
  157. AC_MSG_RESULT(cannot find regular expression library); AC_DEFINE(NO_REGEX)
  158. fi
  159.  
  160. AC_OUTPUT(Makefile)
  161.